package com.yy.controller;


import com.yy.pojo.Result;
import com.yy.pojo.vo.ArticleLogsVo;
import com.yy.service.ArticleLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/logs")
public class ArticleLogsController {

    @Autowired
    private ArticleLogsService articleLogsService;

    /**
     * 记录文章日志
     * @param articleId
     * @return
     */
    @RequestMapping("/article/add")
    public Result add(Integer articleId){
        Integer add = articleLogsService.add(articleId);
        if (add>0){
            return Result.success();
        }else {
            return Result.error("添加日志失败");
        }
    }


    /**
     * 根据用户id获取文章浏览历史记录
     * @return
     */
    @RequestMapping("/article/list")
    public Result<List<ArticleLogsVo>> list(){
        return Result.success(articleLogsService.list());
    }
}
